﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using TestSocektServer.SocketAction;

namespace TestSocektServer
{
    internal class Program
    {
        static void Main(string[] args)
        {
            SocketServer.WebSocketServerStartHelper webSocketServer = new SocketServer.WebSocketServerStartHelper("ws://127.0.0.1:8888");
            //webSocketServer.SetTypes(typeof(TestAction));
            //webSocketServer.SetType<TestAction>();
            //在程序集中查找
            webSocketServer.SetAssemblies(System.Reflection.Assembly.GetExecutingAssembly());
            webSocketServer.Start();
            webSocketServer.SetAttribute(new List<string> { typeof(SocketLogAttribute).FullName });

            var webSocketClient = new WebSocketClientHelper("ws://127.0.0.1:8888");
            webSocketClient.ReceiveMessageEvent += message =>
            {
                Console.WriteLine("服务端输出:\r\n" + message);
            };
            webSocketClient.Start();
            webSocketClient.SendMessage("TestAction/Action1");
            //webSocketClient.SendMessage("TestAction/Action2?IntParamtetr=1&strArray=[\"111\",\"222\"]&strList=[\"aaa\",\"xxx\"]");
            //webSocketClient.SendMessage("TestAction/Action3?Model=" + Newtonsoft.Json.JsonConvert.SerializeObject(new
            //{
            //    Name = "Name",
            //    Value = 222,
            //}));
            Console.WriteLine("按任意键结束");
            Console.ReadKey();
        }
    }
}
